import { _decorator, Component, Node, Prefab, instantiate, director } from 'cc';
import { enemy } from './enemy';
const { ccclass, property } = _decorator;

@ccclass('enemynode')
export class enemynode extends Component {
	@property(Prefab)
	enemynode:Prefab = null
    start() {
		this.schedule(()=>{
			let enemy = instantiate(this.enemynode)
			enemy.setParent(director.getScene().getChildByName('Canvas'))
			enemy.setPosition(
				this.weizhi(Math.random()),
				this.node.getPosition().y
			)
		},0.3)
    }
	weizhi(x){
		if(x<0.5){
			return Math.random()*210
		}else{
			return -Math.random() * 210
		}
		
	}
    update(deltaTime: number) {
        
    }
}

